package com.alex.designPattern.flyWeight;

import java.util.HashMap;
import java.util.Map;

public class CoffeeFactory {
	private Map<String,Coffee> context = new HashMap<String,Coffee>();
	
	public Coffee getCoffee(String typeName) {
		Coffee coffee = context.get(typeName);
		if(coffee == null) {
			coffee = new Coffee();
			coffee.setType(typeName);
			context.put(typeName, coffee);
		}
		return coffee;
	}
	
	public Map<String,Coffee> getContext() {
		return context;
	}
}
